home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2008 May / PersonalComputerWorld-May2008-CoverdiscCD.iso / Software / Full / Nero 7 / Installation / Cab / A97B5616.cab / Spinner566EACA1.js < prev    next >
Encoding:
Text File  |  2006-06-28  |  5.0 KB  |  122 lines

  1.  
  2.  
  3. var counter = 0
  4.  
  5. var spinnerText
  6.  
  7.     
  8.  
  9. function initializeSpinner(oParentContainer)
  10.  
  11.     {
  12.  
  13.         // Box for display of select value
  14.  
  15.         var oSpinnerBox;
  16.  
  17.         // selected <option> element
  18.  
  19.         var oSpinnerSelect;
  20.  
  21.         for (n=0; n<oParentContainer.all.length; n++)
  22.  
  23.         {
  24.  
  25.             var obj = oParentContainer.all[n];
  26.  
  27.             if (obj.MCSpinnerSelect == "true") oSpinnerSelect = obj;
  28.  
  29.             if (obj.MCSpinnerBox == "true") oSpinnerBox = obj;
  30.  
  31.         }
  32.  
  33.         var oSpinnerOptSelected = oSpinnerSelect.options[oSpinnerSelect.selectedIndex];
  34.  
  35.         if (oSpinnerOptSelected == null) oSpinnerOptSelected = oSpinnerSelect.options[0];
  36.  
  37.         // show selected option in Spinner box
  38.  
  39.         oSpinnerBox.innerText = oSpinnerOptSelected.innerText
  40.  
  41.     }
  42.  
  43.     
  44.  
  45. function setSpinner()
  46.  
  47.     {        
  48.  
  49.         // button user clicked
  50.  
  51.         var oClickedBtn = event.srcElement;
  52.  
  53.         // direction (up/down) to move selections, based on button clicked        
  54.  
  55.         var direction
  56.  
  57.         if (oClickedBtn.MCSpinnerPlus=="true")direction = "down";
  58.  
  59.         else direction = "up";
  60.  
  61.         // identifyl all the elements of the spinner; these include
  62.  
  63.         // parent container, plus btn, minus btn, box for display of value, and hidden <select> element.
  64.  
  65.         // Parent container
  66.  
  67.         //var oParentContainer = .parentElement // change this
  68.  
  69.         oParentContainer = getSpinnerParent(oClickedBtn)
  70.  
  71.  
  72.  
  73.         // Box for display of select value
  74.  
  75.         var oSpinnerBox;
  76.  
  77.         // selected <option> element
  78.  
  79.         var oSpinnerSelect;
  80.  
  81.         // Plus btn
  82.  
  83.         var oSpinnerPlus;
  84.  
  85.         //Minus btn
  86.  
  87.         var    oSpinnerMinus;
  88.  
  89.         // selected <option> in <select>
  90.  
  91.         var oSpinnerOptSelected;
  92.  
  93.         // spinner box is parent of <select>
  94.  
  95.         //spinnerBox = oClickedBtn.parentElement;
  96.  
  97.         // find values for all of above, based on their CSS class names
  98.  
  99.         for (i=0; i<oParentContainer.all.length; i++)
  100.  
  101.         {
  102.  
  103.             var obj = oParentContainer.all[i];
  104.  
  105.             // MCSpinnerPlus and MCSpinnerMinus are custom properties set in the HTML tags
  106.  
  107.             // to mark the items as spinner buttons
  108.  
  109.             if (obj.MCSpinnerPlus == "true") oSpinnerPlus = obj;
  110.  
  111.             if (obj.MCSpinnerMinus == "true") oSpinnerMinus = obj;
  112.  
  113.             if (obj.MCSpinnerSelect == "true") oSpinnerSelect = obj;
  114.  
  115.             if (obj.MCSpinnerBox == "true") oSpinnerBox = obj;
  116.  
  117.         }    
  118.  
  119.             
  120.  
  121.  
  122.  
  123.         // find selected option
  124.  
  125.         oSpinnerOptSelected = oSpinnerSelect.options[oSpinnerSelect.selectedIndex];
  126.  
  127.         // variable for next option to display
  128.  
  129.         var oNextOpt;
  130.  
  131.         // set value for next option to display, based on direction (up/down) button clicked
  132.  
  133.         if (direction == "down") oNextOpt = oSpinnerOptSelected.nextSibling;
  134.  
  135.         else oNextOpt = oSpinnerOptSelected.previousSibling;
  136.  
  137.         // if you are on first or last option, oNextOpt might not be valid. If not, stay on current option
  138.  
  139.         if (oNextOpt == null || oNextOpt.tagName == null) 
  140.  
  141.         {
  142.  
  143.             oNextOpt = oSpinnerOptSelected
  144.  
  145.         }
  146.  
  147.         // set oNextOpt as selected element
  148.  
  149.         oNextOpt.selected = true
  150.  
  151.         // (remember, the real select box is invisible) Show selection contents in spinner box
  152.  
  153.         oSpinnerBox.innerText = oNextOpt.innerText
  154.  
  155.         // if there is no next sibling for new selected option, you are at the end, so disable plus btn
  156.  
  157.         if (oNextOpt.nextSibling == null || oNextOpt.nextSibling.tagName == null) 
  158.  
  159.         { 
  160.  
  161.             disableBtn(oSpinnerPlus);
  162.  
  163.             oCurFocus = oSpinnerMinus;
  164.  
  165.             oSpinnerMinus.focus();
  166.  
  167.         }
  168.  
  169.         // else make sure plus btn is enabled
  170.  
  171.         else enableBtn(oSpinnerPlus)
  172.  
  173.         // if there is no previous sibling for new selected option, you are at the beginning, so disable minus btn
  174.  
  175.         if (oNextOpt.previousSibling == null || oNextOpt.previousSibling.tagName == null)
  176.  
  177.         {
  178.  
  179.              disableBtn(oSpinnerMinus);
  180.  
  181.              oCurFocus = oSpinnerPlus;
  182.  
  183.              oSpinnerPlus.focus();
  184.  
  185.         }
  186.  
  187.         // else make sure minus btn is enabled
  188.  
  189.         else enableBtn(oSpinnerMinus)        
  190.  
  191.     }
  192.  
  193.     function getSpinnerParent(btn)
  194.  
  195.     {
  196.  
  197.         var oTempObj = btn
  198.  
  199.         for (i=0; i<5000; i++)
  200.  
  201.         {
  202.  
  203.              oTempObj = oTempObj.parentElement
  204.  
  205.             if (oTempObj.MCSpinnerContainer == "true") 
  206.  
  207.             {
  208.  
  209.                 return oTempObj;
  210.  
  211.                 break;
  212.  
  213.             }
  214.  
  215.             if (oTempObj.tagName == "BODY") return null
  216.  
  217.         }
  218.  
  219.     }
  220.  
  221.     function disableBtn(obj)
  222.  
  223.     {
  224.  
  225.         obj.MCTempUnFocusable = "true"
  226.  
  227.         obj.style.filter = "alpha (opacity = 30)"
  228.  
  229.     }
  230.  
  231.     function enableBtn(obj)
  232.  
  233.     {
  234.  
  235.         // remove temporary unfocusability
  236.  
  237.         if (obj.MCTempUnFocusable == "true")obj.MCTempUnFocusable = "false"
  238.  
  239.         // remove transparency filter
  240.  
  241.         obj.style.filter = "none"
  242.  
  243.     }